﻿<Form @ref="_form" Model="@Model.Data">
    <GridRow>
        <GridCol Span="12">
            <FormItem LabelColSpan="8">
                <Input @bind-Value="@context.Code" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
        <GridCol Span="12">
            <FormItem LabelColSpan="8">
                <Input @bind-Value="@context.Name" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
    </GridRow>
    <GridRow>
        <GridCol Span="12">
            <FormItem LabelColSpan="8">
                <Input @bind-Value="@context.Icon" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
        <GridCol Span="12">
            <FormItem LabelColSpan="8">
                <Switch @bind-Value="@context.Enabled" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
    </GridRow>
    <GridRow>
        <GridCol Span="24">
            <FormItem LabelColSpan="4">
                <Input @bind-Value="@context.Description" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
    </GridRow>
    <GridRow>
        <GridCol Span="24">
            <FormItem LabelColSpan="4">
                <TextArea @bind-Value="@context.Note" Disabled="@Model.IsView" />
            </FormItem>
        </GridCol>
    </GridRow>
</Form>

@code {
    AntDesign.Internal.IForm _form;

    [Parameter] public FormModel<SysModule> Model { get; set; }

    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender)
            Model.OnValidate = _form.Validate;
        base.OnAfterRender(firstRender);
    }
}